﻿#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
int gcd(int a, int b)
{
	//特判除数为0时的情况
	if (b == 0) 
	{
		return a;
	}
	//返回b和a%b的最⼤公约数
	return gcd(b, a % b);
}
int main()
{
	int m = 0, n = 0;
	scanf("%d %d", &m, &n);
	printf("%d\n", gcd(m, n));
	return 0;
}